<!--
 * @Author: 梁卓
 * @Date: 2022-03-07 10:00:57
 * @LastEditTime: 2022-03-07 14:59:22
 * @LastEditors: Please set LastEditors
 * @Description: 试卷历史试题
 * @FilePath: \dreamUi\src\views\exam\examHistory.vue
-->
<template>
  <el-row>
    <el-card>历史测试试卷</el-card>
    <el-card>
      <el-row>
        <el-col :span="5">
          <el-input placeholder="请输入试卷名称" v-model="queryInfo.queryString" clearable  @clear="getInfo"> </el-input>
        </el-col>
        <el-col :span="2">
          <el-button type="primary" @click="getInfo">搜索</el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-table :data="tableData" stripe style="width: 100%">
          <el-table-column prop="paperName" label="试卷标题"/>
          <el-table-column prop="name" label="出题人" />
          <el-table-column prop="paperDate" label="出题时间"/>
          <el-table-column prop="paperTime" label="考试结束时间"/>
        </el-table>
        <el-col :span="24">
          <el-pagination
            v-if="total > 0"
            :currentPage="queryInfo.currentPage"
            :page-sizes="[8,15,30,50]"
            :page-size= "queryInfo.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total= total
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            style="margin-top: 40px;">
          </el-pagination>
        </el-col>
      </el-row>
    </el-card>
  </el-row>
</template>

<script>
export default {
  name: 'DreamuiExamhistory',
  components: {},
  data() {
    return {
      tableData: [],
      queryInfo: {
        pageNumber: 1,
        pageSize: 8,
        queryString: ''
      },
      total: 0,
    };
  },

  mounted() {
    this.getInfo()
  },

  methods: {
    getInfo() {
      this.$ajax.post("/paperInfo/questionInfoPage", this.queryInfo).then(res => {
        this.total = res.data.total
        this.tableData = res.data.rows
      })
    },
    // 改变分页的大小
    handleSizeChange(param) {
      this.queryInfo.pageSize = param;
      // 重新赋值
      this.getInfo();
    },
    // 改变当前页码
    handleCurrentChange(param) {
      this.queryInfo.pageNumber = param;
      this.getInfo();
    },
  },
};
</script>

<style scoped>

</style>